$(document).ready(function() {  
     // banner轮播，拖拽
    $(".banner-img").on(IDXtouchs(IDXgesinfo, 1));
    // banner轮播
    bannerTimer = setInterval(bannerLoop, 4000);
    // 导航条滑动
     // $(".nav-drag ul").on(IDXtouchs(IDXgesinfo, 0));    
    var lilength = $(".nav-drag ul li").length;
    var ulwidth = 0;
    ulwidth += lilength * 134;
    $(".nav-drag ul").width(ulwidth);
    var  Scroll = new iScroll('wrapp',{hScroll: true, hScrollbar:false, vScrollbar:false});
    var  fcoth1 = $("#content-wrap1 .sort-content-type3").children().length;
    var  fcoth2 = $("#content-wrap2 .sort-content-type3").children().length;
    var  ffth = $(".sort-item-type3").width();  
    var  wrap1wh = fcoth1 * (ffth + 30); 
    var  wrap2wh = fcoth2 * (ffth + 30);  
         $("#we-suggest").width(wrap1wh);
         $("#newest-design").width(wrap2wh);

    // 新品推荐下滑块
    // $("#we-suggest").on(IDXtouchs(IDXgesinfo, 2));
   // var wrap1height = $(".pb24").height();
   // $(".content-wrap1").height(wrap1height);
   //  var Scroll = new iScroll('content-wrap1',{hScroll: true, vScroll: false, hScrollbar:false, vScrollbar:false});
    // 最新设计下滑快
    //$("#newest-design").on(IDXtouchs(IDXgesinfo, 2));
    // var Scroll = new iScroll('content-wrap2',{hScroll: true,  hScrollbar:false, vScrollbar:false});
    // 好店推荐
    $("#good-shop").on(IDXtouchs(IDXgesinfo, 3));
    // 新品推荐超出隐藏
    // var $divh = $(".sort-item-type3").height();
    // $(".sort-item-type3").parent().css("height",$divh);    
//以下是轮播图初始化函数
    var swiper_1 = new Swiper('#swiper-1', {
        pagination: '#xi-dian1',
        paginationClickable: true,
        loop: true,
        autoplay: 3000,
    });
    var swiper_2 = new Swiper('#swiper-2', {
        pagination: '#xi-dian2',
        paginationClickable: true,
        loop: true,
        autoplay: 3000,
    });

    var swiper_3 = new Swiper('#swiper-3', {
        slidesPerView: 1.5,
        paginationClickable: true,
        spaceBetween: 5,
        freeMode: true
    });
    var swiper_4 = new Swiper('#swiper-4', {
        slidesPerView: 1.5,
        paginationClickable: true,
        spaceBetween: 5,
        freeMode: true
    });
    var swiper_41 = new Swiper('#swiper-41', {
        slidesPerView: 1.5,
        paginationClickable: true,
        spaceBetween: 5,
        freeMode: true
    });
    var swiper_42 = new Swiper('#swiper-42', {
        slidesPerView: 1.5,
        paginationClickable: true,
        spaceBetween: 5,
        freeMode: true
    });

    var swiper_5 = new Swiper('#swiper-5', {
        pagination: '#xi-dian5',
        paginationClickable: true,
        loop: true,
        autoplay: 3000,
    });

    var swiper_6 = new Swiper('#swiper-6', {
        slidesPerView: 1.5,
        paginationClickable: true,
        spaceBetween: 5,
        freeMode: true
    });

var startPos = 0,endPos = 0,isScrolling = 0;
document.addEventListener('touchstart',function(event){
        var touch = event.targetTouches[0]; //touches数组对象获得屏幕上所有的touch，取第一个touch
        startPos = {x:touch.pageX,y:touch.pageY,time:+new Date}; //取第一个touch的坐标值
        isScrolling = 0; //这个参数判断是垂直滚动还是水平滚动
    }, false);

document.addEventListener('touchmove',function(event){
    //当屏幕有多个touch或者页面被缩放过，就不执行move操作
    if(event.targetTouches.length > 1 || event.scale && event.scale !== 1) return;
    var touch = event.targetTouches[0];
    endPos = {x:touch.pageX - startPos.x,y:touch.pageY - startPos.y};
    isScrolling = Math.abs(endPos.x) < Math.abs(endPos.y) ? 1:0; //isScrolling为1时，表示纵向滑动，0为横向滑动
    if(isScrolling === 0){
        //alert(0);
        event.preventDefault(); //阻止触摸事件的默认行为，即阻止滚屏
    }
}, false);

document.addEventListener('touchend',function(event){
    document.removeEventListener('touchmove',this,false);
    document.removeEventListener('touchend',this,false);
}, false);      

});
